{extend name="public/base" /}
{block name="content"}
<div class="page-content">
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-home"></i>&nbsp;文章管理
            </li>
            <li>文章添加</li>
        </ul>
    </div>
    <!-- /Page Breadcrumb -->
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-xs-12">
                <div class="widget radius-bordered">
                    <div class="widget-header bordered-bottom bordered-themeprimary">
                        <span class="widget-caption">文章添加</span>
                    </div>
                    <div class="widget-body">
                        <form action="" class="form-horizontal">
                            <div class="form-group">
                                <label for="title" class="control-label col-sm-2 no-padding-right">文章标题</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" id="title" name="title" placeholder="文章标题" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="cateid" class="control-label col-sm-2 no-padding-right">所属导航</label>
                                <div class="col-sm-6">
                                    <select id="cateid" name="cateid" class="form-control">
                                        <option value="">请选择</option>
                                        {volist name="cates" id="vo"}
                                        <option value="{$vo.id}">{$vo.catename}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <input type="hidden" name="author" value="{:session('admin.nickname')}">
                            <div class="form-group">
                                <label for="tags" class="control-label col-sm-2 no-padding-right">标签</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" id="tags" name="tags" placeholder="标签">
                                    <span class="help-block">每个标签以|分隔</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" name="aup" value="1">
                                            <span class="text">是否置顶</span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="desc" class="col-sm-2 control-label no-padding-right">文章简要</label>
                                <div class="col-sm-6">
                                    <textarea class="form-control" name="desc" id="desc" cols="30" rows="5"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="content" class="control-label col-sm-2">文章内容</label>
                                <div class="col-sm-6">
                                    <textarea name="content" id="content" cols="30" rows="10" class=""></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-6">
                                    <button class="btn btn-primary" id="articleAdd">添加</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /Page Body -->
</div>
{/block}
{block name="js"}
{__block__}
<script src="/static/lib/ueditor/ueditor.config.js"></script>
<script src="/static/lib/ueditor/ueditor.all.js"></script>
<script>
    UE.getEditor('content');

    $('#articleAdd').click(function () {
        $.ajax({
            url:"{:url('admin/article/articleadd')}",
            type:'post',
            data:$('form').serialize(),
            dataType:'json',
            success:function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {
                        icon:6,
                        time:2000
                    }, function () {
                        location.href = data.url;
                    });
                }else {
                    layer.open({
                        title:'文章发布失败',
                        content:data.msg,
                        icon:5,
                        anim:6
                    });
                }
            }
        });
        return false;
    });
</script>
{/block}